
setTimeout(function(){
	$("#dictionary_Name").val('');
	//$("#dictionary_Name").focus();
	$("#dictionary_Name").rules("add",{
		remote: {
			url: 'sys/dic/checkName'+($("#dictionary_Name").val()+""),
			type: "get",
			dataType: "json", 
			dataFilter:function(data,type){
				return data=="false"?false:true;
			
			}
		}, 
		messages: {remote: "该字典名称已添加"}
	});  
} , parseInt(Math.random() * 1000));


setTimeout(function(){
	$("#dictionary_Code").val('');
	//$("#dictionary_Code").focus();
	$("#dictionary_Code").rules("add",{
		remote: {
			url: 'sys/dic/checkDicCode?code='+$("#dictionary_Code").val()+"&id="+getQueryString("id"),
			type: "get",
			dataType: "json", 
			dataFilter:function(data,type){
				return data=="false"?false:true;
			
			}
		}, 
		messages: {remote: "该字典编码已存在"}
	});  
} , parseInt(Math.random() * 1000));








var app = angular.module('dictionaryApp', []);


app.controller('dictionaryController', function($scope, $http) {
	$scope.dictionary={};
	$scope.dictionary.pid=getQueryString("id");
	$scope.refreshData=function(){
		$scope.dictionary={};
	}
	
	$scope.dicSave=function(){
	   if($("#myForm").valid()){
		   $http.post('sys/dic/addByPid/', $scope.dictionary).success(function(){
              // window.location.href = 'manage/dictionary/dicList.jsp?id='+$scope.dictionary.pid;
               redirectUrl("manage/dictionary/","dicList.jsp?id="+$scope.dictionary.pid);
           });
	   }
	}
	
	$scope.dicReset=function(){
		$scope.dictionary={};
	}
	
	$scope.dicCancle=function(){
		redirectUrl("manage/dictionary/","dicList.jsp?id="+$scope.dictionary.pid);
	}


});